import React,{useState} from 'react';
import { Drawer, Button } from 'antd';
import Dataform from '../dataform/dataform'

const SideMenu=(props)=> {
    const [visible, setVisible] = useState(false);

    const showDrawer = () => {
        setVisible(true);
    };

    const onClose = () => {
        setVisible(false);
    };

    const onMessage= (message)=>{
        console.log(message)
    }

    if (props.value===null){
        return (
            <div>当前未选中任何节点</div>
        );
    }
    return (
        <div>
            当前选中了{props.value}
            <Button type="primary" onClick={showDrawer}>
                编辑
            </Button>
            <Drawer
                title={props.value}
                placement="right"
                closable={true}
                onClose={onClose}
                visible={visible}
            >
                <p>{props.value}</p>
                <div><Dataform value={props.value} hide={onMessage} s_cell={props.s_cell}/></div>
                <p>Some contents...</p>
            </Drawer>
        </div>
    );
}

export default SideMenu;